package com.goldcn;

import com.goldcn.Interceptor.ErpInterceptor;
import com.goldcn.config.*;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.MultipartConfigFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import javax.servlet.MultipartConfigElement;


@SpringBootApplication
@EnableConfigurationProperties({PropertiesConfig.class, FileConfig.class, OSSConfigure.class, FTPConfigure.class, ElasticsearchBean.class})
@EnableEurekaClient
public class Application {
    public static void main(String[] args) {
        final ApplicationContext applicationContext = SpringApplication.run(Application.class, args);
        ErpInterceptor.setApplicationContext(applicationContext);
        //CommonInterceptor.setApplicationContext(applicationContext);
    }

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize("20MB");//限制文件大小
        factory.setMaxRequestSize("20MB");//multipart/form-data requests 的最大值
        factory.setFileSizeThreshold("20MB");
        factory.setLocation("/tmp/sxpfileup");
        return factory.createMultipartConfig();
    }
}